package lsysteem;

import java.util.Hashtable;

public class LSystem implements IModelData
{
	public char axioma;
	public int angle;
	public int maxIterations;
	public Hashtable<Character,LSNode> rules = new Hashtable();
	
	private LSModel _model;
	
	public void addRule(char root, String value)
	{
		LSNode lastRule = null;
		for(char c:value.toCharArray())
		{
			LSNode currentRule = new LSNode();
			currentRule.value = c;
			
			if(lastRule != null) lastRule.next = currentRule;
			else rules.put(root,currentRule);
				
			lastRule = currentRule;
		}
	}
	
	public void registerModel(LSModel m){
		_model = m;
	}
	
	public void notifyModel(){
		_model.setModelData(this);
		_model.updateViews();
	}
}
